import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)


//蓝牙设置
//import Bluetooth from '@/store/bluetooth/index.js'
import Distribution from '@/store/Distribution/index.js'


const store = new Vuex.Store({
	modules: {
		Distribution
	},
	// state: {
	// 	sysinfo: uni.getSystemInfoSync(),//系统信息
	// },
	// mutations: {
	
	// }
	state:{//全局变量定义处
		forcedLogin:true, //是否需要强制登录
		hasLogin:false,   //用户是否登录
		//user:{}      //用于存放用户数据
		userName:"",
		userId:"",
		move_admin:""
	},
	mutations:{//全局方法定义处
		login(state,user){
			state.hasLogin = true;
			state.userName = user.uname || ""
			state.userId = user.uid || ""
			//uni.setStorageSync()
			uni.setStorage({		//把用户信息保存到本地
				key:'userInfo',
				data:user
			})
			uni.setStorageSync('hasLogin', true);
		
		},
		logout(state){
			state.hasLogin = false;
			state.userName = ""
			state.userId = ""
			uni.removeStorage({
				key:'userInfo'  //根据键值移除对应的缓存数据
			})
 
			uni.setStorageSync('hasLogin', false);
			
		},
		
		
		
		
	}
})

export default store
